package Code;

import java.util.Scanner;

/*
需求：卖飞机票
机票价格按照淡季旺季、头等舱和经济舱收费，输入机票原价，月份和头等舱或经济舱。
按照如下规则计算机票价格：旺季（5-10月）头等仓9折，经济舱8.5折，淡季（11月-来年4月头等舱7折，经济舱6折）
 */
public class Test1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入机票原价");
        double price = scanner.nextDouble();
        System.out.println("请输入月份：");
        int moonth = scanner.nextInt();
        System.out.println("请输入头等舱（0）或者经济舱（1）:");
        int seat = scanner.nextInt();

        System.out.println(AirTicket(price, moonth, seat));
    }

    public static double AirTicket(double price, int month, int sear) {
        if (month >= 5 && month <= 10) {
            price = getPrice(price, sear, 0.9, 0.58);

        } else if ((month > 0 && month < 5) || (month > 10 && month <= 12)) {
            price = getPrice(price, sear, 0.7, 0.65);
        }
        return price;
    }

    public static double getPrice(double ticket, int seat, double v0, double v1) {
        if (seat == 0) {
            ticket *= v0;
        } else if (seat == 1) {
            ticket *= v1;
        }
        return ticket;
    }
}
